package com.lwlean.test.quartz;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Map;

/**
 * Created by lean on 2017/1/25.
 */
@Configuration
public class FactoryBeanAutoConfiguration {

    @Autowired
    private JobDetailBean jobDetailBean;
    @Autowired
    private Map<String,Object> jobDataAsMap;

    @Value("${quartz.runtime}")
    private String runtime;

    @Bean(name = "testJob")
    public JobDetailBean testJob(){
        jobDataAsMap.put("name",20);
        return new JobDetailBean("com.lwlean.test.quartz.TestTask",jobDataAsMap);
    }

    @Bean
    public CronTriggerBean testTrigger(JobDetailBean testJob){
        final CronTriggerBean cronTriggerBean = new CronTriggerBean(testJob, runtime);
//        cronTriggerBean.start();
        return cronTriggerBean;
    }

}
